package com.atguigu.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * 后置处理器:初始化前后进行处理工作
 *  将后置处理器加入到容器中
 * @author gcq
 * @Create 2020-09-22
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    /**
     *
     * @param bean 容器创建的实例
     * @param beanName bean在容器中的名字
     * @return
     * @throws BeansException
     */
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization..." + beanName);
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization..." + beanName);
        return bean;
    }
}